<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>SystemSharp: LongPathDirectory.cs Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">SystemSharp
   &#160;<span id="projectnumber">0.3</span>
   </div>
   <div id="projectbrief">A system-level modeling framework for designing real-time embedded systems</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_long_path_directory_8cs_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Properties</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Events</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">LongPathDirectory.cs</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_long_path_directory_8cs.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//     Copyright (c) Microsoft Corporation.  All rights reserved.</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="keyword">using</span> System;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keyword">using</span> System.Collections.Generic;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="keyword">using</span> System.Diagnostics.Contracts;</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="keyword">using</span> System.IO;</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="keyword">using</span> System.Runtime.InteropServices;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="keyword">using</span> Microsoft.Experimental.IO.Interop;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="keyword">namespace </span>Microsoft.Experimental.IO {</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html">   15</a></span>&#160;    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">class </span><a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html">LongPathDirectory</a> {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#af56b42bf2bead0d88faef9f66112cf1e">   60</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#af56b42bf2bead0d88faef9f66112cf1e">Create</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;            <span class="keywordtype">string</span> normalizedPath = LongPathCommon.NormalizeLongPath(path);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            <span class="keywordflow">if</span> (!NativeMethods.CreateDirectory(normalizedPath, IntPtr.Zero)) {</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;                <span class="comment">// To mimic Directory.CreateDirectory, we don&#39;t throw if the directory (not a file) already exists</span></div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;                <span class="keywordtype">int</span> errorCode = Marshal.GetLastWin32Error();</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;                <span class="keywordflow">if</span> (errorCode != NativeMethods.ERROR_ALREADY_EXISTS || !<a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html">LongPathDirectory</a>.<a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#adc2a7a27f2d9598e08c8720cc682c592">Exists</a>(path)) {</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                    <span class="keywordflow">throw</span> LongPathCommon.GetExceptionFromWin32Error(errorCode);</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                }</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            }</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        }</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#aced3ccbdfba0a85bf9d78b2c60d4964d">  124</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#aced3ccbdfba0a85bf9d78b2c60d4964d">Delete</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;            <span class="keywordtype">string</span> normalizedPath = LongPathCommon.NormalizeLongPath(path);</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;            <span class="keywordflow">if</span> (!NativeMethods.RemoveDirectory(normalizedPath)) {</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;                <span class="keywordflow">throw</span> LongPathCommon.GetExceptionFromLastWin32Error();</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;            }</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        }</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div>
<div class="line"><a name="l00150"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#adc2a7a27f2d9598e08c8720cc682c592">  150</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#adc2a7a27f2d9598e08c8720cc682c592">Exists</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;            <span class="keywordtype">bool</span> isDirectory;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;            <span class="keywordflow">if</span> (LongPathCommon.Exists(path, out isDirectory)) {</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;                <span class="keywordflow">return</span> isDirectory;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;            }</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;            <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;        }</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div>
<div class="line"><a name="l00203"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a489181e29f8c4edc36bffbd74cb11bb6">  203</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a489181e29f8c4edc36bffbd74cb11bb6">EnumerateDirectories</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;            <span class="keywordflow">return</span> EnumerateDirectories(path, (<span class="keywordtype">string</span>)null);</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;        }</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;</div>
<div class="line"><a name="l00257"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a290f7a1382d89a444358c3f7204e5a2b">  257</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a290f7a1382d89a444358c3f7204e5a2b">EnumerateDirectories</a>(<span class="keywordtype">string</span> path, <span class="keywordtype">string</span> searchPattern) {</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;            <span class="keywordflow">return</span> EnumerateFileSystemEntries(path, searchPattern, includeDirectories: <span class="keyword">true</span>, includeFiles: <span class="keyword">false</span>);</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;        }</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;</div>
<div class="line"><a name="l00304"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a438669d17e4219bd26f733d7636e230d">  304</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a438669d17e4219bd26f733d7636e230d">EnumerateFiles</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;            <span class="keywordflow">return</span> EnumerateFiles(path, (<span class="keywordtype">string</span>)null);</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;        }</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;</div>
<div class="line"><a name="l00358"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a243e44f47ef4c7a0abbf2225249f0b04">  358</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a243e44f47ef4c7a0abbf2225249f0b04">EnumerateFiles</a>(<span class="keywordtype">string</span> path, <span class="keywordtype">string</span> searchPattern) {</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;            <span class="keywordflow">return</span> EnumerateFileSystemEntries(path, searchPattern, includeDirectories: <span class="keyword">false</span>, includeFiles: <span class="keyword">true</span>);</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;        }</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;</div>
<div class="line"><a name="l00406"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a3038b1ea6f941a9867b817f85488f2fb">  406</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a3038b1ea6f941a9867b817f85488f2fb">EnumerateFileSystemEntries</a>(<span class="keywordtype">string</span> path) {</div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;            <span class="keywordflow">return</span> EnumerateFileSystemEntries(path, (<span class="keywordtype">string</span>)null);</div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;        }</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;</div>
<div class="line"><a name="l00460"></a><span class="lineno"><a class="line" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a371dc604f607e1992f39998c30611dd6">  460</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; <a class="code" href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a371dc604f607e1992f39998c30611dd6">EnumerateFileSystemEntries</a>(<span class="keywordtype">string</span> path, <span class="keywordtype">string</span> searchPattern) {</div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;            <span class="keywordflow">return</span> EnumerateFileSystemEntries(path, searchPattern, includeDirectories: <span class="keyword">true</span>, includeFiles: <span class="keyword">true</span>);</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;        }</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;        <span class="keyword">private</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; EnumerateFileSystemEntries(<span class="keywordtype">string</span> path, <span class="keywordtype">string</span> searchPattern, <span class="keywordtype">bool</span> includeDirectories, <span class="keywordtype">bool</span> includeFiles) {</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;            <span class="keywordtype">string</span> normalizedSearchPattern = LongPathCommon.NormalizeSearchPattern(searchPattern);</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;            <span class="keywordtype">string</span> normalizedPath = LongPathCommon.NormalizeLongPath(path);</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;            <span class="comment">// First check whether the specified path refers to a directory and exists</span></div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;            FileAttributes attributes;</div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;            <span class="keywordtype">int</span> errorCode = LongPathCommon.TryGetDirectoryAttributes(normalizedPath, out attributes);</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;            <span class="keywordflow">if</span> (errorCode != 0) {</div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;                <span class="keywordflow">throw</span> LongPathCommon.GetExceptionFromWin32Error(errorCode);</div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;            }</div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;            <span class="keywordflow">return</span> EnumerateFileSystemIterator(normalizedPath, normalizedSearchPattern, includeDirectories, includeFiles);</div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;        }</div>
<div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;</div>
<div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;        <span class="keyword">private</span> <span class="keyword">static</span> IEnumerable&lt;string&gt; EnumerateFileSystemIterator(<span class="keywordtype">string</span> normalizedPath, <span class="keywordtype">string</span> normalizedSearchPattern, <span class="keywordtype">bool</span> includeDirectories, <span class="keywordtype">bool</span> includeFiles) {</div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;            <span class="comment">// NOTE: Any exceptions thrown from this method are thrown on a call to IEnumerator&lt;string&gt;.MoveNext()</span></div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;            <span class="keywordtype">string</span> path = LongPathCommon.RemoveLongPathPrefix(normalizedPath);</div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;</div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;            NativeMethods.WIN32_FIND_DATA findData;</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;            <span class="keyword">using</span> (SafeFindHandle handle = BeginFind(Path.Combine(normalizedPath, normalizedSearchPattern), out findData)) {</div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;                <span class="keywordflow">if</span> (handle == null)</div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;                    yield <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;</div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;                <span class="keywordflow">do</span> {</div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;                    <span class="keywordtype">string</span> currentFileName = findData.cFileName;</div>
<div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;</div>
<div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;                    <span class="keywordflow">if</span> (IsDirectory(findData.dwFileAttributes)) {</div>
<div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;                        <span class="keywordflow">if</span> (includeDirectories &amp;&amp; !IsCurrentOrParentDirectory(currentFileName)) {</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;                            yield <span class="keywordflow">return</span> Path.Combine(path, currentFileName);</div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;                        }</div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;                    }</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;                    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;                        <span class="keywordflow">if</span> (includeFiles) {</div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;                            yield <span class="keywordflow">return</span> Path.Combine(path, currentFileName);</div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;                        }</div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;                    }</div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;                } <span class="keywordflow">while</span> (NativeMethods.FindNextFile(handle, out findData));</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;</div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;                <span class="keywordtype">int</span> errorCode = Marshal.GetLastWin32Error();</div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;                <span class="keywordflow">if</span> (errorCode != NativeMethods.ERROR_NO_MORE_FILES)</div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;                    <span class="keywordflow">throw</span> LongPathCommon.GetExceptionFromWin32Error(errorCode);</div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;            }</div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;        }</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;</div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;        <span class="keyword">private</span> <span class="keyword">static</span> SafeFindHandle BeginFind(<span class="keywordtype">string</span> normalizedPathWithSearchPattern, out NativeMethods.WIN32_FIND_DATA findData) {</div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;            </div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;            SafeFindHandle handle = NativeMethods.FindFirstFile(normalizedPathWithSearchPattern, out findData);</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;            <span class="keywordflow">if</span> (handle.IsInvalid) {</div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;</div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;                <span class="keywordtype">int</span> errorCode = Marshal.GetLastWin32Error();</div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;                <span class="keywordflow">if</span> (errorCode != NativeMethods.ERROR_FILE_NOT_FOUND)</div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;                    <span class="keywordflow">throw</span> LongPathCommon.GetExceptionFromWin32Error(errorCode);</div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;</div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;                <span class="keywordflow">return</span> null;</div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;            }</div>
<div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;</div>
<div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;            <span class="keywordflow">return</span> handle;  </div>
<div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;        }</div>
<div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;</div>
<div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;        <span class="keyword">internal</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> IsDirectory(FileAttributes attributes) {</div>
<div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;</div>
<div class="line"><a name="l00528"></a><span class="lineno">  528</span>&#160;            <span class="keywordflow">return</span> (attributes &amp; FileAttributes.Directory) == FileAttributes.Directory;</div>
<div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;        }</div>
<div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160;</div>
<div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;        <span class="keyword">private</span> <span class="keyword">static</span> <span class="keywordtype">bool</span> IsCurrentOrParentDirectory(<span class="keywordtype">string</span> directoryName) {</div>
<div class="line"><a name="l00532"></a><span class="lineno">  532</span>&#160;</div>
<div class="line"><a name="l00533"></a><span class="lineno">  533</span>&#160;            Contract.Requires&lt;ArgumentNullException&gt;(directoryName != null);</div>
<div class="line"><a name="l00534"></a><span class="lineno">  534</span>&#160;            <span class="keywordflow">return</span> directoryName.Equals(<span class="stringliteral">&quot;.&quot;</span>, StringComparison.OrdinalIgnoreCase) || directoryName.Equals(<span class="stringliteral">&quot;..&quot;</span>, StringComparison.OrdinalIgnoreCase);</div>
<div class="line"><a name="l00535"></a><span class="lineno">  535</span>&#160;        }</div>
<div class="line"><a name="l00536"></a><span class="lineno">  536</span>&#160;    }</div>
<div class="line"><a name="l00537"></a><span class="lineno">  537</span>&#160;}</div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a243e44f47ef4c7a0abbf2225249f0b04"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a243e44f47ef4c7a0abbf2225249f0b04">Microsoft.Experimental.IO.LongPathDirectory.EnumerateFiles</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateFiles(string path, string searchPattern)</div><div class="ttdoc">Returns a enumerable containing the file names of the specified directory that match the specified se...</div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00358">LongPathDirectory.cs:358</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a371dc604f607e1992f39998c30611dd6"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a371dc604f607e1992f39998c30611dd6">Microsoft.Experimental.IO.LongPathDirectory.EnumerateFileSystemEntries</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateFileSystemEntries(string path, string searchPattern)</div><div class="ttdoc">Returns a enumerable containing the file and directory names of the specified directory that match th...</div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00460">LongPathDirectory.cs:460</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a438669d17e4219bd26f733d7636e230d"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a438669d17e4219bd26f733d7636e230d">Microsoft.Experimental.IO.LongPathDirectory.EnumerateFiles</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateFiles(string path)</div><div class="ttdoc">Returns a enumerable containing the file names of the specified directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00304">LongPathDirectory.cs:304</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_aced3ccbdfba0a85bf9d78b2c60d4964d"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#aced3ccbdfba0a85bf9d78b2c60d4964d">Microsoft.Experimental.IO.LongPathDirectory.Delete</a></div><div class="ttdeci">static void Delete(string path)</div><div class="ttdoc">Deletes the specified empty directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00124">LongPathDirectory.cs:124</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a290f7a1382d89a444358c3f7204e5a2b"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a290f7a1382d89a444358c3f7204e5a2b">Microsoft.Experimental.IO.LongPathDirectory.EnumerateDirectories</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateDirectories(string path, string searchPattern)</div><div class="ttdoc">Returns a enumerable containing the directory names of the specified directory that match the specifi...</div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00257">LongPathDirectory.cs:257</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_adc2a7a27f2d9598e08c8720cc682c592"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#adc2a7a27f2d9598e08c8720cc682c592">Microsoft.Experimental.IO.LongPathDirectory.Exists</a></div><div class="ttdeci">static bool Exists(string path)</div><div class="ttdoc">Returns a value indicating whether the specified path refers to an existing directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00150">LongPathDirectory.cs:150</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html">Microsoft.Experimental.IO.LongPathDirectory</a></div><div class="ttdoc">Provides methods for creating, deleting, moving and enumerating directories and subdirectories with l...</div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00015">LongPathDirectory.cs:15</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a489181e29f8c4edc36bffbd74cb11bb6"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a489181e29f8c4edc36bffbd74cb11bb6">Microsoft.Experimental.IO.LongPathDirectory.EnumerateDirectories</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateDirectories(string path)</div><div class="ttdoc">Returns a enumerable containing the directory names of the specified directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00203">LongPathDirectory.cs:203</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_a3038b1ea6f941a9867b817f85488f2fb"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#a3038b1ea6f941a9867b817f85488f2fb">Microsoft.Experimental.IO.LongPathDirectory.EnumerateFileSystemEntries</a></div><div class="ttdeci">static IEnumerable&lt; string &gt; EnumerateFileSystemEntries(string path)</div><div class="ttdoc">Returns a enumerable containing the file and directory names of the specified directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00406">LongPathDirectory.cs:406</a></div></div>
<div class="ttc" id="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory_html_af56b42bf2bead0d88faef9f66112cf1e"><div class="ttname"><a href="class_microsoft_1_1_experimental_1_1_i_o_1_1_long_path_directory.html#af56b42bf2bead0d88faef9f66112cf1e">Microsoft.Experimental.IO.LongPathDirectory.Create</a></div><div class="ttdeci">static void Create(string path)</div><div class="ttdoc">Creates the specified directory. </div><div class="ttdef"><b>Definition:</b> <a href="_long_path_directory_8cs_source.html#l00060">LongPathDirectory.cs:60</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bb5e995590685548b7e11478911ee7c3.html">SystemSharp-Google-SVN</a></li><li class="navelem"><a class="el" href="dir_8deefa4467a62b572b52d238d562b104.html">SystemSharp</a></li><li class="navelem"><a class="el" href="dir_0e5a72156f8560bbc472a395da2569d6.html">SystemSharp</a></li><li class="navelem"><a class="el" href="dir_8fc67bbcc3526c8d762754b2841c296e.html">Microsoft</a></li><li class="navelem"><a class="el" href="dir_189ee8a8e9ab4f559109b12e56785d43.html">Experimental</a></li><li class="navelem"><a class="el" href="dir_60b5ea59483aca65819dd517ac50b181.html">IO</a></li><li class="navelem"><a class="el" href="_long_path_directory_8cs.html">LongPathDirectory.cs</a></li>
    <li class="footer">Generated on Thu Dec 26 2013 14:21:40 for SystemSharp by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
